<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>atividade extra-classe</title>
         <script type="text/javascript" src="../js/jquery.js" ></script>
        <script type="text/javascript" src="../js/jquery.validate.js"></script>
        <script type="text/javascript" src="../js/jquery-ui-1.8.2.custom.min.js" ></script>
        <script type="text/javascript" src="../js/jquery.ui.datepicker-pt-BR.js" ></script>
        <script type="text/javascript" src="../js/forms.js"></script>
        <link rel="stylesheet" href="../css/ui-lightness/jquery-ui-1.8.2.custom.css">
        <link rel="stylesheet" href="../css/forms.css">
        </head>
    <script>$(document).ready(function(){
        $("#form").validate({
            rules: {
                matricula: {required: true}
                ,id_tipoafastamento: {required: true,digits: true
                }
                ,desc_afastamento: {required: true}
                ,data_inicio: {required: true}
                ,data_fim: {required: true}
                ,data_validado: {}
                ,situacao_afastamento: {}
                ,carga_horaria: {digits: true
                }
                ,id_setor_solicitante: {digits: true
                }
            },
            submitHandler: function(form) {
                salvar(form);
            }
        });
    });

    $(function() {
        $("#data_inicio").datepicker();
        $("#data_fim").datepicker();

    });
    </script>

    </head>
    <body>
        
        <form name="form" id="form" method="post" action="insert.jsp" >
                <fieldset><legend>Dados</legend>
                    <input type="hidden" id="matricula"  name="matricula" size="6" maxlength="6" class="required" value="${param.matricula}">
                    <p><label class="lbInput">Tipo<em>*</em></label>
                        <sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
                            SELECT  * FROM TipoAfastamento
                            order by desc_tipoafastamento
                        </sql:query>
                        <select name="id_tipoafastamento" class="required" >
                            <c:forEach var="row" items="${query.rows}">
                                <option value="${row.id_tipoafastamento}">${row.desc_tipoafastamento}</option>
                            </c:forEach>
                        </select>
                    </p>
                    <p><label class="lbInput">Descrição<em>*</em></label>
                        <textarea name="desc_afastamento" class="required" rows="5" cols="50"></textarea>
                    </p>
                    <p><label class="lbInput">Início<em>*</em></label>
                        <input type="text" id="data_inicio" name="data_inicio" size="10" maxlength="10" class="required">
                    </p>
                    <p><label class="lbInput">Fim<em>*</em></label>
                        <input type="text" id="data_fim" name="data_fim" size="10" maxlength="10" class="required">
                    </p>
                    <p><label class="lbInput">Área solicitante</label>
                        <sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
                            SELECT  setores.*, desc_unidade FROM Setores
                            inner join unidades on setores.id_unidade=unidades.id_unidade
                            order by desc_setor
                        </sql:query>
                        <select name="id_setor_solicitante">
                            <option value="">Não se aplica</option>
                            <c:forEach var="row" items="${query.rows}">
                                <option value="${row.id_setor}">${row.desc_unidade}-${row.desc_setor}</option>
                            </c:forEach>
                        </select>
                    </p>
                    <p><label class="lbInput">Carga Horária</label>
                        <input type="text" name="carga_horaria" size="10" maxlength="10">
                    </p>
                    <p>
                        <input class="submit" type="submit" value="Salvar">
                        <input class="submit" type="button" value="Remover" onclick="remover(document.forms[0])" style="visibility:hidden">
                        <input class="submit" type="button" value="Listar" onclick="listar('fm_lista_Afastamentos.jsp')">
                    </p>
                </fieldset>
                <div id="msg">

                </div>
        <input type="hidden" id="token" name="token" value="${sessionScope.token}" /> </form>
    </body>
</html>
